package com.asset.salesforce.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.apache.solr.analysis.LowerCaseFilterFactory;
import org.apache.solr.analysis.SnowballPorterFilterFactory;
import org.apache.solr.analysis.StandardTokenizerFactory;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.TokenizerDef;

@SuppressWarnings("serial")
@Entity
@Table(name = "employee")
@Indexed
@AnalyzerDef(name="employeeAnalyzer", tokenizer = @TokenizerDef(factory=StandardTokenizerFactory.class),
filters={@TokenFilterDef(factory=LowerCaseFilterFactory.class),
        @TokenFilterDef(factory=SnowballPorterFilterFactory.class,params={
                @Parameter(name="language",value="English")
        })
})
public class Employee implements Serializable {
	
	private Integer id;
	private File photo;
	private String empInfo;
	private String fName;
	private String lName;
	private String nickName;
	private String email;
	private Company company;
	private Country country;
	private JobTitle jobTitle;
	private Employee manager;
	private Boolean isActive;
	private Boolean isOwner;
	private Boolean firstLogin;
	private Set<Employee> employees;
	private Boolean isFollowed;
	private Date dateCreated;
	private Date dateModified;
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="employee_id_seq")
	@SequenceGenerator(name="employee_id_seq",sequenceName="employee_id_seq",allocationSize=1)
	@DocumentId
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the photo
	 */
	@OneToOne
	@JoinColumn(name = "photo_id")
	public File getPhoto() {
		return photo;
	}
	/**
	 * @param photo the photo to set
	 */
	public void setPhoto(File photo) {
		this.photo = photo;
	}
	/**
	 * @return the empInfo
	 */
	@Column(name="emp_info")
	public String getEmpInfo() {
		return empInfo;
	}
	/**
	 * @param empInfo the empInfo to set
	 */
	public void setEmpInfo(String empInfo) {
		this.empInfo = empInfo;
	}
	/**
	 * @return the fName
	 */
	@Column(name="f_name")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public String getfName() {
		return fName;
	}
	/**
	 * @param fName the fName to set
	 */
	public void setfName(String fName) {
		this.fName = fName;
	}
	/**
	 * @return the lName
	 */
	@Column(name="l_name")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public String getlName() {
		return lName;
	}
	/**
	 * @param lName the lName to set
	 */
	public void setlName(String lName) {
		this.lName = lName;
	}
	/**
	 * @return the nickName
	 */
	@Column(name="nick_name")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public String getNickName() {
		return nickName;
	}
	/**
	 * @param nickName the nickName to set
	 */
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	/**
	 * @return the email
	 */
	@Column(name="email")
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the company
	 */
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="company_id")
	@IndexedEmbedded
	public Company getCompany() {
		return company;
	}
	/**
	 * @param company the company to set
	 */
	public void setCompany(Company company) {
		this.company = company;
	}
	/**
	 * @return the country
	 */
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="country_id")
	public Country getCountry() {
		return country;
	}
	/**
	 * @param country the country to set
	 */
	public void setCountry(Country country) {
		this.country = country;
	}
	/**
	 * @return the jobTitle
	 */
	@ManyToOne
	@JoinColumn(name="job_title_id")
	public JobTitle getJobTitle() {
		return jobTitle;
	}
	/**
	 * @param jobTitle the jobTitle to set
	 */
	public void setJobTitle(JobTitle jobTitle) {
		this.jobTitle = jobTitle;
	}
	/**
	 * @return the manager
	 */
	@ManyToOne
	@JoinColumn(name="manager_id")
	public Employee getManager() {
		return manager;
	}
	/**
	 * @param manager the manager to set
	 */
	public void setManager(Employee manager) {
		this.manager = manager;
	}
	/**
	 * @return the isActive
	 */
	@Column(name="is_active")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public Boolean getIsActive() {
		return isActive;
	}
	/**
	 * @param isActive the isActive to set
	 */
	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}
	/**
	 * @return the isOwner
	 */
	@Column(name="is_owner")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public Boolean getIsOwner() {
		return isOwner;
	}
	/**
	 * @param isOwner the isOwner to set
	 */
	public void setIsOwner(Boolean isOwner) {
		this.isOwner = isOwner;
	}
	/**
	 * @return the firstLogin
	 */
	@Column(name="first_login")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public Boolean getFirstLogin() {
		return firstLogin;
	}
	/**
	 * @param firstLogin the firstLogin to set
	 */
	public void setFirstLogin(Boolean firstLogin) {
		this.firstLogin = firstLogin;
	}
	/**
	 * @return the employees
	 */
	@OneToMany(mappedBy="manager")
	public Set<Employee> getEmployees() {
		return employees;
	}
	/**
	 * @param employees the employees to set
	 */
	public void setEmployees(Set<Employee> employees) {
		this.employees = employees;
	}
	/**
	 * @return the isFollowed
	 */
	@Transient
	public Boolean getIsFollowed() {
		return isFollowed;
	}
	/**
	 * @param isFollowed the isFollowed to set
	 */
	public void setIsFollowed(Boolean isFollowed) {
		this.isFollowed = isFollowed;
	}
	/**
	 * @return the dateCreated
	 */
	@Temporal(value=TemporalType.TIMESTAMP)
	@Column(name="date_created")
	@Field(index=Index.YES,store=Store.NO)
	@Analyzer(definition = "employeeAnalyzer")
	public Date getDateCreated() {
		return dateCreated;
	}
	/**
	 * @param dateCreated the dateCreated to set
	 */
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	/**
	 * @return the dateModified
	 */
	@Temporal(value = TemporalType.TIMESTAMP)
	@Column(name="date_modified")
	public Date getDateModified() {
		return dateModified;
	}
	/**
	 * @param dateModified the dateModified to set
	 */
	public void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}
	
}
	
		
